package cqcvc.edu.cn.servlet;

import cqcvc.edu.cn.dao.ActivityDao;
import cqcvc.edu.cn.entity.ActivityInfo;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;

@WebServlet(name = "ActivityImageShowServlet",urlPatterns = "/activity_image_show")
public class ActivityImageShowServlet extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        ActivityDao hd=new ActivityDao();
        Long id=Long.parseLong(request.getParameter("id"));
        ActivityInfo house=hd.findById(id);
        byte[] img=house.getActPic();
        if(img!=null)
        {
            OutputStream ou=response.getOutputStream();
            ou.write(img);
            ou.flush();
            ou.close();
        }
    }
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
